Skip to content

Method: handleCall(CallableStatement, int)

1: package de.fhdw.wtf.persistence.utils;
2:
3: import java.sql.CallableStatement;
4: import java.sql.SQLException;
5:
6: import de.fhdw.wtf.persistence.exception.NotValidInputException;
7: import de.fhdw.wtf.persistence.meta.Object;
8: import de.fhdw.wtf.persistence.meta.UserObject;
9:
10: /**
11: * Wrapper for a UserObject for a Database-Query.
12: */
13: public class DBConnectionUserObjectHandler implements DBConnectionObjectHandler {
14:         
15:         private final UserObject userObject;
16:         
17:         @Override
18:         public String getObjectTypeString() {
19:                 return "UO";
20:         }
21:         
22:         @Override
23:         public void handleCall(final CallableStatement call, final int parameterIndex) throws SQLException {
24:                 call.setLong(parameterIndex, this.userObject.getId());
25:         }
26:         
27:         @Override
28:         public Object getObject() {
29:                 return this.userObject;
30:         }
31:         
32:         /**
33:          * creates a wrapper for a user object for a database connection.
34:          *
35:          * @param userObject
36:          * the wrapped user object
37:          * @throws NotValidInputException
38:          * throws when the given string is null
39:          */
40:         public DBConnectionUserObjectHandler(final UserObject userObject) throws NotValidInputException {
41:                 super();
42:                 
43:                 if (userObject == null) {
44:                         throw new NotValidInputException("userObject");
45:                 }
46:                 
47:                 this.userObject = userObject;
48:         }
49: }